package com.paradogs.gs.misc;

import com.paradogs.gs.misc.exceptions.BizException;
import com.paradogs.gs.modules.Player;
import com.paradogs.gs.utils.PlayerUtils;
import lombok.val;

import java.net.BindException;

/**
 * @author: yumi
 * @date: 2024/10/28  22:54
 * @Description: 用于各种快速方法调用 Bow!
 */
public class Bow {

    public static void err(int code) {
        throw new BizException(code);
    }
    public static void err(String msg) {
        throw new BizException(msg);
    }

    public static Player owner() {
        return PlayerUtils.cur();
    }


    public static void asserts(boolean valid, String msg) {
        if (!valid) {
            Bow.err(msg);
        }
    }
    public static void asserts(boolean valid) {
        if (!valid) {
            Bow.err("系统异常");
        }
    }

    public static <T> T def(T val, T defaultVal) {
        return val != null ? val : defaultVal;
    }


}
